#include "No7pch.h"
#include "OrthographicCamera.h"

#include <glm/gtc/matrix_transform.hpp>

nmspc::OrthographicCamera::OrthographicCamera(float left, float right, float bottom, float top) :
	projection_matrix(glm::ortho(left, right, bottom, top, -1.0f, 1.0f)),
	view_matrix(1.0f)
{
	this->view_projection_matrix = this->projection_matrix * this->view_matrix;
}

void nmspc::OrthographicCamera::recalculateViewMatrix()
{
	glm::mat4 transform = glm::translate(glm::mat4(1.0f), this->position) * glm::rotate(glm::mat4(1.0f), glm::radians(this->rotation), glm::vec3(0, 0, 1));
	this->view_matrix = glm::inverse(transform);
	this->view_projection_matrix = this->projection_matrix * this->view_matrix;
}
